<template>
	<view class="community">
		<view class="head_bg" style="position: relative;"></view>
		<view class="big_box" style="top: -200rpx;">
			<view class="big_box_inner" style="top:30rpx;">
				<view v-if="list.length>0" class="big_inner_one" style="padding: 10rpx 0;" v-for="(info,index) in list" :key="index">
					<view class="plot_inner" @tap="todetail(info)" style="height: auto;padding: 15rpx 0;margin-bottom: 10rpx;">
						<view class="plot_inner_left">
							<view class="notice_title">{{info.title}}</view>
							<view class="notice_time">{{info.create_time}} </view>
						</view>
						<view class="plot_inner_left">
							<image class="plot_inner_img" src="../../../common/img/zhankai.png" mode=""></image>
						</view>
					</view>
				</view>
				<view style="height:100rpx;"></view>
				<view v-if="list.length==0" class="margin-top-lg text-center">
					<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
				</view>
				<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
					{{loadingTxt}} 共({{totle}}条记录)
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				loadingTxt:'加载更多',
				list:{},
				total:0,
				info:{
				  _id:0,//	整型	ID
				  title:'',//	字符串	标题
				  content:'',//	字符串	内容
                  create_time:'',
				}
			}
		},
		onShow() {
			page=1
			this.getInfo();
		},
		methods: {
			todetail(obj){
                console.log(obj)
				uni.navigateTo({
					url: '../noticeDetail/noticeDetail?obj='+encodeURIComponent(JSON.stringify(obj))
				})
			},
			getInfo(){
				let that=this;
				let pan = that.pageindex;
				that.http.tokenreq({
					url: 'info/v1/noticelist',
					data: {
				    "pageindex":page
					}
				}).then((res) => {
					let e=res.data;
					console.log(e);
					if(e.code==0 && e.success){
						this.list = e.rows;
						this.totle= e.total;
						page++;
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				that.http.tokenreq({
					url: 'info/v1/noticelist',
					data: {
					"pageindex":page
					}
				}).then((res) => {
					console.log("res="+JSON.stringify(res));
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.rows);
						page++;
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
				// this.getMoreNews()
			},
		}
	}
</script>
<style>
	page{
		background-color: #FFFFFF;
	}
	.big_inner_one{
		margin-bottom:20rpx;
	}
</style>
